#ifndef BOARD_H
#define BOARD_H

#include <QWidget>
#include <QPaintEngine>
#include <QVector>
#include <CETable.h>

enum {a=0, b, c, d, e, f, g, h};

namespace Ui {
    class Board;
}



struct Piece
{
    QImage img;
    QPair<int, int> position;
    int type;
    bool isWhite;
};

const short success_move = 0;
const short invalid_move = -1;
const short incorrect_move = -2;
const short unknown_figure = -3;
const short figure_not_found = -4;
const short bad_figure = 5;

class Board : public QWidget
{
    Q_OBJECT

public:
    explicit Board(QWidget *parent = 0);
    ~Board();
    void paintEvent(QPaintEvent *);
    void setTable(ChEngn::Table table);

private:

    static QImage getImageFor(ChEngn::piece_type type, bool isWhite);

    static void convertPos(const int l_pos,
                    const int n_pos,

                    int& r_l_pos,
                    int& r_n_pos);
    static void convertPosToAbsolute(const int l_pos, const int n_pos,
                                     int& a_l_pos, int& a_n_pos);
    Ui::Board *ui;

    ChEngn::Table m_table;
};

#endif // BOARD_H
